package org.medusa.db;

import org.medusa.db.handlersocket.InsertResult;
import org.medusa.db.handlersocket.ModifyResult;
import org.medusa.db.handlersocket.QueryOneResult;
import org.medusa.db.handlersocket.QueryResult;

public abstract class SyncDBConnector {

	public abstract boolean IsConnected();

	public abstract Error Close();

	public abstract InsertResult Insert(String dbName, String tableName,
			String indexName, String[] columns, Object[] vals);

	public abstract ModifyResult Modify(String dbName, String tableName,
			String indexName, String oper, Object[] keys, String[] columns,
			Object[] newvals, int limit, int skip);

	public ModifyResult Modify(String dbName, String tableName,
			String indexName, String oper, Object[] keys, String[] columns,
			Object[] newvals) {
		return this.Modify(dbName, tableName, indexName, oper, keys,
				columns, newvals, Integer.MAX_VALUE, 0);
	}

	public abstract ModifyResult Remove(String dbName, String tableName,
			String indexName, String oper, Object[] keys, int limit, int skip);

	public ModifyResult Remove(String dbName, String tableName,
			String indexName, String oper, Object[] keys) {
		return this.Remove(dbName, tableName, indexName, oper, keys, Integer.MAX_VALUE, 0);
	}

	public abstract QueryResult Query(String dbName, String tableName, String indexName,
			String oper, Object[] keys, String[] columns, int limit, int skip);

	public QueryResult Query(String dbName, String tableName, String indexName,
			String oper, Object[] keys, String[] columns) {
		return this.Query(dbName, tableName, indexName, oper, keys, columns, Integer.MAX_VALUE, 0);
	}

	public abstract QueryOneResult QueryOne(String dbName, String tableName,
			String indexName, String oper, Object[] keys, String[] columns,
			int skip);

	public QueryOneResult QueryOne(String dbName, String tableName,
			String indexName, String oper, Object[] keys, String[] columns) {
		return this.QueryOne(dbName, tableName, indexName, oper, keys, columns, 0);
	}

}
